﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;


namespace QuanLyHocBongSinhVien.DAO
{
    public class NamHoc_DAO
    {
        dbConnection db = new dbConnection();
        public DataTable getAllNamHoc()
        {
            return db.ExecuteQuery("select * from NAMHOC");
        }

        public DataTable getMaNH()
        {
            string sql = "Select MANAMHOC from NAMHOC";
            return db.ExecuteQuery(sql);
        }

        public void themNH(string ma, string hk)
        {
            SqlParameter[] mang = new SqlParameter[2];
            mang[0] = new SqlParameter("@manh", ma);
            mang[1] = new SqlParameter("@hocki", hk);
            db.ExecuteNonQuery("Them_NamHoc", mang);
        }

        public void suaNH(string ma, string hk)
        {
            SqlParameter[] mang = new SqlParameter[2];
            mang[0] = new SqlParameter("@manh", ma);
            mang[1] = new SqlParameter("@hocki", hk);
            db.ExecuteNonQuery("Sua_NamHoc", mang);
        }
        public void xoaNH(string ma)
        {
            SqlParameter[] mang = new SqlParameter[1];
            mang[0] = new SqlParameter("@manh", ma);
            db.ExecuteNonQuery("Xoa_NamHoc", mang);
        }

        public void TimKiemNH(string ma)
        {
            SqlParameter[] mang = new SqlParameter[1];
            mang[0] = new SqlParameter("@manh", ma);
            db.ExecuteNonQuery("TimKiem_NamHoc", mang);
        }   
    }
}
